clear;

% src = fullfile("D:\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\T90_WideBandRCS_CST\theta=90,phi=(0,0.2,360),8-10GHz\");
% dst = fullfile("D:\ATR_Data_Simulation\T90_HRRPDataBase\theta=90,phi=(0,0.2,360),8-10GHz,SNR=20dB\");

% DELL-XPS:laptop
% src_APC = fullfile("D:\baiduDisk\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\APC_WideBandRCS_CST\theta=90,phi=(0,0.2,360),8-10GHz\");
% src_T90 = fullfile("D:\baiduDisk\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\T90_WideBandRCS_CST\theta=90,phi=(0,0.2,360),8-10GHz\");

% ASUS:PC
src_T90 = fullfile("D:\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\T90\theta=85,phi=(0,0.01,180),8-10GHz\");
src_M1A1 = fullfile("D:\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\M1A1\theta=85,phi=(0,0.01,180),8-10GHz\");
src_APC = fullfile("D:\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\APC\theta=85,phi=(0,0.01,180),8-10GHz\");
src_Shilka = fullfile("D:\BaiduNetdiskWorkspace\RATR_GAN_based\DATA\Shilka\theta=85,phi=(0,0.01,180),8-10GHz\");

dst = fullfile("D:\Users\Data\matlab\cls_four_tgts_sigma=0.01\");

% set signal-to-noise ratio
sigma = 0.01;
    

%% 生成噪声数据
% 大小为256*4*12000
data_size = [256, 4, 12000];
HRRP = sigma*(randn(data_size)+1j*randn(data_size));
save(dst+"Noise.mat", "HRRP")


%%
% APC_dl = CSTDataLoader(src_APC, dst, ... 
%     "batch_size",1024, ...
%     "is_processed",false, ...
%     "num_freq",257, ...
%     "SNR",SNR, ...
%     "tag","APC");    
% 
% partial(APC_dl,[0 209.9],[90 90],'train');
% partial(APC_dl,[330 359.9],[90 90],'train');
% 
% partial(APC_dl,[210 250-0.1],[90 90],'test');
% partial(APC_dl,[290 330-0.1],[90 90],'test');
% 
% partial(APC_dl,[250 290-0.1 ],[90 90],'validation');

%%
T90_dl = CSTDataLoader(src_T90, dst, "T90",... 
    "batch_size",1024, ...
    "num_freq",129, ...
    "nfft", 256,...
    "sigma",sigma, ...
    "save_mode","all-in-one");   

hrrp_from_txt(T90_dl);

partial(T90_dl,[0 120],[85 86],'train');
partial(T90_dl,[120 150],[85 86],'test');
partial(T90_dl,[150 180],[85 86],'validation');

%% M1A1
M1A1_dl = CSTDataLoader(src_M1A1, dst, "M1A1", ... 
    "batch_size",1024, ...
    "num_freq",129, ...
    "nfft", 256,...
    "sigma",sigma, ...
    "save_mode","all-in-one");   

hrrp_from_txt(M1A1_dl);

partial(M1A1_dl,[0 120],[85 86],'train');
partial(M1A1_dl,[120 150],[85 86],'test');
partial(M1A1_dl,[150 180],[85 86],'validation');

%%
APC_dl = CSTDataLoader(src_APC, dst, "APC",... 
    "batch_size",1024, ...
    "num_freq",129, ...
    "nfft", 256,...
    "sigma",sigma, ...
    "save_mode","all-in-one");   

hrrp_from_txt(APC_dl);

partial(APC_dl,[0 120],[85 86],'train');
partial(APC_dl,[120 150],[85 86],'test');
partial(APC_dl,[150 180],[85 86],'validation');

%%
Shilka_dl = CSTDataLoader(src_Shilka, dst, "Shilka",... 
    "batch_size",1024, ...
    "num_freq",129, ...
    "nfft", 256,...
    "sigma",sigma, ...
    "save_mode","all-in-one");   

hrrp_from_txt(Shilka_dl);

partial(Shilka_dl,[0 120],[85 86],'train');
partial(Shilka_dl,[120 150],[85 86],'test');
partial(Shilka_dl,[150 180],[85 86],'validation');

%%

% Boxer_dl = CSTDataLoader(src_Boxer, dst, ... 
%     "batch_size",1024, ...
%     "is_processed",false, ...
%     "num_freq",257, ...
%     "SNR",SNR, ...
%     "tag","Boxer");    
% 
% partial(T90_dl,[0 120],[85 86],'train');
% partial(T90_dl,[120 150],[85 86],'test');
% partial(T90_dl,[150 181],[85 86],'validation');

%%

% Leopard_dl = CSTDataLoader(src_Leopard2, dst, ... 
%     "batch_size",1024, ...
%     "is_processed",false, ...
%     "num_freq",257, ...
%     "SNR",SNR, ...
%     "tag","Leopard2");    
% 
% partial(Leopard_dl,[0 209.9],[90 90],'train');
% partial(Leopard_dl,[330 359.9],[90 90],'train');
% 
% partial(Leopard_dl,[210 250-0.1],[90 90],'test');
% partial(Leopard_dl,[290 330-0.1],[90 90],'test');
% 
% partial(Leopard_dl,[250 290-0.1 ],[90 90],'validation');

%%
% APC_dl = CSTDataLoader(src_APC, dst, ... 
%     "batch_size",1024, ...
%     "is_processed",false, ...
%     "num_freq",257, ...
%     "SNR",SNR, ...
%     "tag","APC");     
% 
% 
% 
% 
% partial(APC_dl,[0 209.9],[90 90],'train');
% partial(APC_dl,[330 359.9],[90 90],'train');
% 
% partial(APC_dl,[210 250-0.1],[90 90],'test');
% partial(APC_dl,[290 330-0.1],[90 90],'test');
% 
% partial(APC_dl,[250 290-0.1 ],[90 90],'validation');
% 
% %%
% T90_dl = CSTDataLoader(src_T90, dst, ...
%     "batch_size",1024, ...
%     "is_processed",false, ...
%     "num_freq",257, ...
%     "SNR",SNR, ...
%     "tag","T90");     
% 
% preview(T90_dl,"all")
% 
% partial(T90_dl,[0 119.9],[90 90],'train');
% partial(T90_dl,[240 359.9],[90 90],'train');
% 
% partial(T90_dl,[120 160-0.1],[90 90],'test');
% partial(T90_dl,[200 240-0.1],[90 90],'test');
% 
% partial(T90_dl,[160 200-0.1 ],[90 90],'validation');